/*
 * Copyright 2009 Original Author(s)
 * 
 * This file is part of Kommando
 * 
 * Kommando is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Kommando is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Kommando.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.kommando.core.selector;

import java.util.List;

import org.kommando.core.HistoryTracker;
import org.kommando.core.KommandoWindow;
import org.kommando.core.action.Action;
import org.kommando.core.catalog.Catalog;
import org.kommando.core.catalog.CatalogObject;
import org.kommando.core.search.CatalogObjectSearcher;
import org.kommando.core.search.Result;

/**
 * @author Peter De Bruycker
 * 
 */
public class IndirectObjectSelector extends CatalogObjectSelector {

    private CatalogObjectSearcher searcher = new CatalogObjectSearcher();
    private Action action;

    public IndirectObjectSelector(CommandSelector commandSelector, Catalog catalog, HistoryTracker historyTracker) {
        super(commandSelector, KommandoWindow.Selector.INDIRECT, catalog, historyTracker);
    }

    /**
     * @see org.kommando.core.selector.AbstractSelector#doSearch(java.util.List, java.lang.String)
     */
    @Override
    protected List<Result<CatalogObject>> doSearch(List<CatalogObject> candidates, String query) {
        return searcher.searchObjects(getHistoryTracker(), candidates, query, action.getIndirectTypes());
    }

    public void setAction(Action action) {
        this.action = action;
    }
}
